from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# 设置 Desired Capabilities
capabilities = DesiredCapabilities.CHROME.copy()
capabilities['platform'] = 'WINDOWS'  # 指定操作系统
capabilities['version'] = 'latest'    # 指定浏览器版本

# 连接到 Selenium Grid Hub
driver = webdriver.Remote(
    command_executor='http://<hub-ip>:4444/wd/hub',
    desired_capabilities=capabilities
)

# 执行测试
driver.get("https://www.example.com")
print(driver.title)
driver.quit()